package service;

import sensorgui.Sensor;

import com.agentfactory.logic.agent.Actuator;
import com.agentfactory.logic.lang.FOS;

public class MoveSensor extends Actuator {
	
	 public boolean act(FOS action) {
		 
	        String direction = action.argAt(0).toString();

	        SensorNetPlatformService snet = (SensorNetPlatformService) this.getService("sensornet");

	        if (snet == null) {
	            return false;
	        }
	        
	        Sensor sens = snet.lookupSensor(agent.getName());
	        
	        if (direction.equalsIgnoreCase("right")
	        		&& sens.canMoveRight()) {
	        	sens.moveRight();
	        	System.out.println("Moving Right");
	        	
	        }
	        
	        if (direction.equalsIgnoreCase("left")
	        		&& sens.canMoveLeft()) {
	        	sens.moveLeft();
	        	System.out.println("Moving left");
	        	
	        }
	        
	        return true;
	    }
	

}
